
import 'package:baselib/widgets/comm_select_widget.dart';
import 'package:baselib/widgets/dialog_util.dart';
import 'package:flutter/material.dart';
import 'package:framelib/utils/px_util.dart';
import 'package:framelib/widgets/datetime_picker/date_picker.dart';
import 'package:framelib/widgets/datetime_picker/date_picker_theme.dart';

class SelectUtil{
  static void showDatetimePicker(
      BuildContext context, {
        DateTime initialDateTime,
        Function onConfirm,
      }) {
    DatePicker.showDatePicker(
      context,
      dateFormat: 'dd-MM-yyyy',
      maxDateTime: DateTime.now(),
      initialDateTime: initialDateTime,
      pickerTheme: DateTimePickerTheme(
        itemTextStyle: TextStyle(
          fontSize: PxUtil.instance.px_14,
          color: Colors.white,
        ),
        titleHeight: PxUtil.instance.px_38,
        pickerHeight: PxUtil.instance.px_164,
        itemHeight: PxUtil.instance.px_48,
      ),
      onConfirm: (DateTime dateTime, List<int> selectedIndex) {
        if (onConfirm != null) {
          onConfirm(dateTime);
        }
      },
    );
  }

  /*普通单选*/
  static commSelect({
    List<String> datas,
    int initIndex,
    Function onSelectedItemChanged,
    Function onConfirm,
    Function onCancel
  }){
    //CommSelectWidget
    Future popParams = DialogUtil.instance.showBottomSheet(
      child: CommSelectWidget(
        datas: datas,
        initIndex: initIndex,
        onSelectedItemChanged: onSelectedItemChanged,
        onConfirm: onConfirm,
        onCancel: onCancel,
      )
    );
  }


}
